home *** CD-ROM | disk | FTP | other *** search
- /* $VER: A.02 ARexxGuide.rexx (05.14.93) by Robin Evans
-
- This is still rough. It doesn't save the AG command to envarc: yet, for
- one thing, but it should fix some of the previous problems (and create
- a few new ones, I'm sure.
-
- Load xref files for ARexxGuide
- */
- signal ON ERROR /* AmigaGuide returns a '216' error code on some systems */
- signal ON FAILURE
-
- call setclip('TextCodes', "csi='9b'x;slant=csi'3m';bold=csi'1m';norm=csi'0m';black=csi'31m';white=csi'32m';blue=csi'33m'")
- XrefFile = 'ARx_Guide.xref'
-
- if ~show('L','amigaguide.library') then
- call addlib('amigaguide.library',-2,-30,0)
- if ~show('L','rexxsupport.library') then
- call addlib('rexxsupport.library',0,-30,0)
-
- /* Function returns either 1 if rexxarplib is available or **
- ** 0 if it isn't. [Willy] can be used later as the condition **
- ** in IF statements. */
- Willy = CheckRxArp() /* load rexxarplib if we have it */
-
- if loadxref(XrefFile) then do
- call pragma(s, 8192)
- /* This won't work because ARexx commands cannot be executed **
- ** from a AG window opened in this manner */
- /* call shownode(,'ARexxGuide.guide', 'MAIN') */
- /* options failat 217 */
- if ~show('P', ARX_GUIDE) then do
- AGCmd = getenv('ARexxGuide/AGCmd')
- if abbrev(AGCmd, 'Multi') then
- PrtOpt = ''
- else
- PrtOpt = 'portname ARX_GUIDE'
-
- /* we return a number if it's a bad name */
- if datatype(AGCmd,'N') then do
- say 'Improper name for AmigaGuide utility:' AGCmd
- signal error
- end
- address command AGCmd 'ARexxGuide.guide' PrtOpt
- /* the AG library still seems to cause some incompatibility **
- ** with rexxarplib. Besides it's big. So this removes it. */
- call expungexref()
- call remlib('amigaguide.library')
- end
- else do
- address ARX_GUIDE
- 'windowtofront'
- 'ActivateWindow'
- /* don't know if this next one makes sense. It might be better **
- ** to just show the current document???? */
- /* 'link ArexxGuide.guide/MAIN' */
- end
- end
- else do
- interpret getclip('TextCodes')
- say 'Couldn''t find xref file.'
- say white'Please make sure the AmigaGuide path '
- say 'variable is set (press HELP in AmigaGuide'
- say 'for more info) and includes the path where'
- say 'the "Arx_" files are located.'black
- end
-
- exit 0
-
- ERROR:
- FAILURE:
- call expungexref()
- call remlib('amigaguide.library')
- exit
-
-
- /* This uses rexxarplib's GETENV() if it's here */
- GetEnv: procedure expose Willy
-
- AGCmd = ''
- if Willy then
- AGCmd = 'GetEnv'(arg(1))
- else if open(.Env, 'env:'arg(1), R) then do
- AGCmd = readln(.Env)
- call close .Env
- end
-
- if AGCmd = '' | ~exists(AGCmd) then
- AGCmd = SetAGCmd(Willy)
-
- return AGCmd
-
- SetAGCmd: procedure
-
- arg Willy
- InfoMsg = 'The program needs information about\the location of your AmigaGuide utility.\Please choose the program you use\to view AmigaGuide files.'
- if Willy then do
- call PostMsg(10,0,InfoMsg)
- AGCmd = GetFile(10,55,,,"Choose AmigaGuide utility",,PATGAD,,356,145)
- call PostMsg()
- end
- else do
- call close STDOUT
- if open(STDOUT, 'con:10/0/346/145/Choose AmigaGuide utility',W) then do
- call close STDIN
- call open(STDIN, '*', R)
- /* pragma('*') is redundant on 2.0+ and WShell, but... */
- call pragma('*', STDIN); call pragma('*', STDOUT)
- end
- /* if that didn't work we'll try for the best with the standard **
- ** window defined in the icon (if that was used) */
- say translate(InfoMsg, '0a'x, '\')'0a'x
- interpret getclip('TextCodes')
- do forever /* Break after checking for existence of file at end */
- say blue'Please enter complete path of the'
- say 'program. Enter program name as well.'black
- options prompt black'Program?' white'::: 'black
- parse pull AGCmd
- if ~exists(AGCmd) | AGCmd = '' then do
- say AGCmd 'is not a valid file name'
- say blue'Try again?'
- options prompt white'(y/n) ::: 'black
- pull resp
- if abbrev(resp, 'Y') then iterate
- end
- break
- end
- call close STDOUT
- call close STDIN
- call pragma('*') /* which doesn't work... grrrrr */
- end
-
- if AGCmd > '' & exists(AGCmd) then do
- call makedir('env:ARexxGuide')
- if open(.EnvFile, 'env:ARexxGuide/AGCmd', W) then
- call writech(.EnvFile, AGCmd)
- call close .EnvFile
- end
- else return 10
-
- return AGCmd
-
- CheckRxArp: procedure
-
- signal on syntax /* this will catch the unloaded library */
- if ~show('L', 'rexxarplib.library') then do
- call addlib('rexxarplib.library',0,-30,0)
- call PostMsg()
- end
- return 1 /* The syntax sub. will return 0 if it isn't available */
-
- Syntax:
- /* only CheckRxArp has this turned on, so being here means there **
- ** is no rexxarplib.library */
- call remlib('rexxarplib.library')
- return 0
-